﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace ACC.Extensions.PCClient.Entities
{
    /// <summary>
    /// 是否显示的装换器
    /// </summary>
    public class VisibilityConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (bool)value ? "Visible" : "Hidden";
        }
        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

     /// <summary>
    /// 条码显示颜色
    /// </summary>
    public class BarcodeColorConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (BarcodeStatus)value == BarcodeStatus.NOK ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EA5555")) :
                               new SolidColorBrush((Color)ColorConverter.ConvertFromString("#333333"));

        }
        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 连接状态背景色装换器
    /// </summary>
    public class LogBackgroundColorConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (bool)value ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EA5555")) :
                               new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F4F7FC"));
        }

        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 连接状态背景色装换器
    /// </summary>
    public class LogForegroundColorConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (bool)value ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF")) :
                               new SolidColorBrush((Color)ColorConverter.ConvertFromString("#333333"));
        }

        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 连接状态背景色装换器
    /// </summary>
    public class ConnectedColorConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (bool)value ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2DCA73")) :
                               new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EA5555"));
        }

        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 配置是否显示的装换器
    /// </summary>
    public class BoolVisibilityConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int type = (int)value;
            return type==3 ? "Visible" : "Hidden";
        }
        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    /// <summary>
    /// 配置是否显示的装换器
    /// </summary>
    public class StringVisibilityConverter : IValueConverter
    {
        /// <summary>  
        /// 正向转  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int type = (int)value;
            return type != 3 ? "Visible" : "Hidden";
        }
        /// <summary>  
        /// 逆向转未用到  
        /// </summary>  
        /// <param name="value"></param>  
        /// <param name="targetType"></param>  
        /// <param name="parameter"></param>  
        /// <param name="culture"></param>  
        /// <returns></returns>  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
